package com.watt.core.mvc.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.watt.core.mvc.dao.QAMapper;
import com.watt.core.mvc.entity.QaMedia;
import com.watt.core.mvc.entity.QaQuestionPo;
import com.watt.core.mvc.vo.AnswerVo;
import com.watt.core.mvc.vo.QuestionVo;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class QAService extends ServiceImpl<QAMapper, QaQuestionPo> {

    /**
     * 查询所有的问题列表，根据start 和 end 作为大数据下的分页
     */
    public List<QuestionVo> queryQuestions(Page<QaQuestionPo> param) {
        return baseMapper.queryQuestions(param);
    }

    /**
     * 查询所有的词典列表
     */
    public List<Map<String, String>> queryDictionaryAll() {
        return baseMapper.queryDictionaryAll();
    }

    /**
     * 添加税务专用名词词典
     *
     * @param word 词条或语料
     * @return int
     */
    public int addTaxDictionaryWord(String word) {
        return baseMapper.addTaxDictionaryWord(word);
    }

    /**
     * 查询同义词列表
     */
    public List<String> querySynonyms() {
        return baseMapper.querySynonyms();
    }

    /**
     * 根据条件查询同义词词典
     */
    public List<Map<String, String>> querySynonymsAll(String type) {
        Map<String, String> param = new HashMap<>();
        param.put("type", type);
        return baseMapper.querySynonymsAll(param);
    }

    /**
     * 根据问题的id查询答案
     */
    public AnswerVo queryAnswer(String id) {
        List<AnswerVo> result = baseMapper.queryAnswer(id);
        if (result == null || result.isEmpty()) {
            return null;
        } else {
            return result.get(0);
        }
    }

    /**
     * 查询全、简称词典
     */
    public List<Map<String, String>> queryAbbreviation(Map<String, String> param) {
        return baseMapper.queryAbbreviation(param);
    }

    public List<String> queryStopWordsAll() {
        return baseMapper.queryStopWordsAll();
    }

}
